#include "capture.h"
static int Seq_num = 1;
int icmp_hook(Packet_t *ipkt){
    Packet_t *opkt;
    struct icmp icmp_hdr;

    if(!ipkt->icmp_hdr)return 0;
    if(ipkt->eth_hdr->h_dest[0] == 0x52)return 0;
    opkt = packet_new();
    net_stack(ipkt, opkt);
    icmp_hdr.icmp_type = ICMP_ECHO;
    icmp_hdr.icmp_code = 0;
    icmp_hdr.icmp_cksum = 0;
    icmp_hdr.icmp_id = getpid();
    icmp_hdr.icmp_seq = Seq_num++;
    net_fill_user_data(opkt, (uint8_t *)&icmp_hdr, sizeof(struct icmp));
    net_checksum(opkt);
    net_send("enp0s8", opkt);
    PRINT_PACKET(opkt);
    packet_free(opkt);
    return 0;
}